package com.zh.login.controller;

import com.zh.user.entity.SysRole;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Description:
 * @ClassName TestGroup
 * @date: 2021.04.16 09:38
 * @Author: zhanghang
 */
public class TestGroup {

    public static void main(String[] args) {
        List<Group> list = new ArrayList<>();
        list.add(new Group("1","1"));
        list.add(new Group("2","2"));
        list.add(new Group("3","3"));
        list.add(new Group("3","3"));
        list.add(new Group("4","4"));
        list.add(new Group("4","4"));
        Map<String, Long> collect = list.stream().collect(Collectors.groupingBy(Group::getId, Collectors.counting()));
        System.out.println(collect);
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    static class Group {
        private String id;
        private String name;
    }
}
